package com.legendshop.openportal.sdk.model.request;

import com.legendshop.openportal.sdk.annotation.JsonValid;
import com.legendshop.openportal.sdk.model.BaseRequest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

import static com.legendshop.openportal.sdk.model.constants.ApiPathConstants.GET_FREIGHT;

/**
 * 订单运费
 *
 * @author EDaoren
 */
@Data
@ApiModel("查询订单运费请求")
public class OrderFreightRequest extends BaseRequest {

	private static final long serialVersionUID = 8500998664502515187L;

	/**
	 * 非空：是
	 *
	 * [{“prodId”:商品编号1,“skuId”:规格编号1,”num”:商品数量1},{“prodId”:商品编号2,“skuId”:规格编号2,”num”:商品数量2}] OrderSkuQueryInfo
	 * （最多支持50种商品）
	 */
	@ApiModelProperty(value = "商品列表，请把参数转为json字符串", example = "[{“prodId”:商品编号1,“skuId”:规格编号1,”num”:商品数量1},{“prodId”:商品编号2,“skuId”:规格编号2,”num”:商品数量2}]")
	@NotBlank(message = "商品列表不能为空")
	@JsonValid(target = OrderSkuQueryInfo.class, isArrayJson = true, message = "sku不是jsonArr类型字段")
	private String sku;
//	private List<@Valid OrderSkuQueryInfo> skuList;

	/**
	 * 非空：是
	 * 一级地址
	 */
	@ApiModelProperty("一级地址")
	@NotNull(message = "一级地址不能为空")
	private Long province;

	/**
	 * 非空：是
	 * 二级地址
	 */
	@ApiModelProperty("二级地址")
	@NotNull(message = "二级地址不能为空")
	private Long city;

	/**
	 * 非空：是
	 * 三级地址
	 */
	@ApiModelProperty("三级地址")
	@NotNull(message = "三级地址不能为空")
	private Long area;

	/**
	 * 非空：是
	 * 四级地址  (如果该地区有四级地址，则必须传递四级地址，没有四级地址则传0)
	 */
	@ApiModelProperty("四级地址")
	@NotNull(message = "四级地址不能为空")
	private Long town;

	@Override
	@ApiModelProperty(hidden = true)
	public String getApiPath() {
		return GET_FREIGHT;
	}

	/**
	 * sku信息
	 * [{“skuId”:商品编号1,”num”:商品数量1},{“skuId”:商品编号2,”num”:商品数量2}]
	 */
	@Data
	@NoArgsConstructor
	@AllArgsConstructor
	public static class OrderSkuQueryInfo implements Serializable {

		private static final long serialVersionUID = -5985258983133958763L;

		/**
		 * 商品ID
		 */
		@ApiModelProperty("商品ID")
		@NotNull(message = "商品ID不能为空")
		private Long prodId;

		/**
		 * skuId
		 */
		@ApiModelProperty("skuId")
		@NotNull(message = "规格ID不能为空")
		private Long skuId;

		/**
		 * 下单数量
		 */
		@ApiModelProperty("下单数量")
		@NotNull(message = "商品数量不能为空")
		private Integer num;

	}
}



